package com.xielx.ohs.bean;

import java.io.Serializable;
import java.net.URLEncoder;
import java.util.Map;
import java.util.Map.Entry;
import org.springframework.util.CollectionUtils;

public class OhsParam
  implements Serializable
{
  private String method;
  private String url;
  private Map<String, String> params;
  private Map<String, String> header;

  public String getMethod()
  {
    return this.method;
  }

  public void setMethod(String method) {
    this.method = method;
  }

  public Map<String, String> getParams() {
    return this.params;
  }

  public void setParams(Map<String, String> params) {
    this.params = params;
  }

  public Map<String, String> getHeader() {
    return this.header;
  }

  public void setHeader(Map<String, String> header) {
    this.header = header;
  }

  public String getUrl() {
    return this.url;
  }

  public void setUrl(String url) {
    this.url = url;
  }

  public String getFullUrl() {
    if (CollectionUtils.isEmpty(this.params)) {
      return this.url;
    }
    if (!this.url.contains("?")) {
      this.url += "?";
    }
    try {
      for (Entry<String, String> entry : this.params.entrySet()) {
        this.url = (this.url + (String)entry.getKey() + "=" + URLEncoder.encode((String)entry.getValue(), "UTF-8") + "&");
      }
    } catch (Exception e) {
      e.printStackTrace();
    }
    return this.url;
  }
}